﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>热表理化申请维护</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
</head>
<body>
    <div class="panelSection">
        <div class="easyui-panel " title="查询区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <form action="#" id="queryForm">
            <div style="margin: 3px 0px 3px 3px">
                <div style="float: left;">
                    <div class="divLabel" style="margin-bottom: 5px">
                        检测项目：</div>
                    <select style='width: 120px; height: 20px' id='txtCheckItemName_qf'
                        data-options="editable:false,panelHeight:'auto'" class='easyui-combobox'>
                    </select>
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        零件号：</div>
                    <input id="txtProductName_qf" name="productName" class="easyui-textbox" style="width: 180px;
                        height: 20px" />
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        工序号：</div>
                    <input id="txtSpecNo_qf" name="specNo" class="easyui-textbox" style="width: 150px;
                        height: 20px" />
                </div>
                <div style="float: left; margin-left: 20px">
                    <button id="btnSearch" type="button" class="easyui-linkbutton" style="margin-top: 16px;
                        width: 120px">
                        查询</button>
                    <button id="btnReset" type="button" class="easyui-linkbutton" style="margin-top: 16px;
                        margin-left: 5px; width: 80px">
                        重置</button>
                </div>
                <div style="clear: both">
                </div>
            </div>
            </form>
        </div>
    </div>
    <div class="panelSection">
        <div class="easyui-panel " title="列表区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <div style="margin: 3px 0px 3px 3px; height: 60%">
                <table id="gdCheckInfo" class="easyui-datagrid" style="width: 100%; height: 100%"
                    data-options="rownumbers:true,fitColumns:true,singleSelect:true,selectOnCheck:true">
                </table>
                <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                    buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]  
                ">
                </div>
            </div>
        </div>
    </div>
    <div class="panelSection">
        <div class="easyui-panel " title="编辑区域" style="padding: 3px;" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
            <div style="margin: 3px 0px 3px 3px">
                <form id="editForm" action="">
                <input type="hidden" id="txtPhysicoChemicalCheckId" name="physicoChemicalCheckId" />
                <div style="float: left; margin-top: -2px">
                    <div id="productContent">
                    </div>
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        工序：</div>
                    <select id="txtWorkflowStepName_ef" name="workflowStepName" data-options="editable:false,panelHeight:'auto',required:true"
                        class='easyui-combobox' style="width: 150px; height: 20px">
                    </select>
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        检测项目：</div>
                    <select style='width: 120px; height: 20px' id='txtCheckItemName_ef' name="checkItemName"
                        data-options="editable:false,panelHeight:'auto',required:true" class='easyui-combobox'>
                    </select>
                </div>
                <div style="float: left; margin-left: 10px">
                    <div class="divLabel" style="margin-bottom: 5px">
                        检测标准：</div>
                    <input id="txtCheckStandard_ef" name="checkStandard" class="easyui-textbox" style="width: 180px;
                        height: 20px" data-options="required:true" />
                </div>
                <div style="float: left; margin-left: 10px">
                    <button id="btnSave" class="easyui-linkbutton" type="button" style="width: 120px;
                        height: 21px; margin-top: 16px">
                        保存</button>
                </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ProductLinkageWorkflow.js"
    type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：zhangrj
    日期：2025-04-16
    描述：热表理化申请维护js
    */
    var page = {
        pageTotal: 0,
        pageSize: 20,
        pageNumber: 1,
        rootPath: getRootPath(), //网站根路径
        url: getRootPath() + "/Ashx/ReBiaoConainer/RbPhysicoChemicalCheckHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            page.initPageData();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        //页面加载完之前
        before: function () {
            //件号下拉绑定
            $("#productContent").productCombo({
                cancel: function () { //取消时，清空工序下拉框
                    $("#txtWorkflowStepName_ef").combo("clear");
                    $("#txtWorkflowStepName_ef").combo("panel").empty();
                },
                selected: function (val, text) {
                    page.bindSpecData(val); //绑定工序下拉列表
                }
            });
        },
        //页面事件绑定
        bind: function () {
            //列表加载
            $("#gdCheckInfo").datagrid({
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pageTotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'PRODUCTNAME', title: '零件号', width: 180 },
                 { field: 'WORKFLOWSTEPNAME', title: '工序', width: 150 },
                 { field: 'CHECKITEMNAME', title: '检测项目', width: 120 },
                 { field: 'CHECKSTANDARD', title: '检测标准', width: 150 },
                 { field: 'CREATEEMPNAME', title: '创建人', width: 150 },
                 { field: 'CREATETIME', title: '创建日期', width: 100,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD');
                         }
                     }
                 },
                 { field: 'UPDATEEMPNAME', title: '修改人', width: 150 },
                 { field: 'UPDATETIME', title: '修改日期', width: 100,
                     formatter: function (value, row, index) {
                         if (!isNullOrWhiteSpaceStr(value)) {
                             return dayjs(value).format('YYYY-MM-DD');
                         }
                     }
                 }
                ]],
                onSelect: function (rowIndex, rowData) {
                    page.bindEditFormData(rowData);
                },
                onUnselect: function (rowIndex, rowData) {
                    page.clearPage(false, false, true);
                }
            });
            //查询按钮
            $('#btnSearch').on("click", function () {
                page.clearPage(false, true, true);
                page.searchData();
            });
            //保存按钮
            $('#btnSave').on("click", function () {
                page.saveData();
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.searchData();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.searchData();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                page.clearPage(true, true, true);
            });
        },
        //初始化页面数据
        initPageData: function () {
            page.post(page.url, { action: "GetPhysicoChemicalCheckPageData" }, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                $("#txtCheckItemName_qf").combobox({
                    valueField: 'ITEMID',
                    textField: 'ITEMNAME',
                    panelHeight: 200,
                    data: res.DBTable //下拉数据
                });
                $("#txtCheckItemName_ef").combobox({
                    valueField: 'ITEMID',
                    textField: 'ITEMNAME',
                    panelHeight: 200,
                    data: res.DBTable //下拉数据
                });
                $("#txtPhysicoChemicalCheckId").val(""); //将编辑数据ID隐藏框置为空
            });
        },
        //查询
        searchData: function () {
            var params = {
                pageSize: page.pageSize,
                pageIndex: page.pageNumber,
                checkItemName: $("#txtCheckItemName_qf").combobox("getText")
            };
            var queryFormData = $("#queryForm").serializeArray();
            $.each(queryFormData, function () {
                params[this.name] = this.value;
            });
            page.post(page.url, { action: "GetPhysicoChemicalCheckList", paramDatas: JSON.stringify(params) }, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                page.pageTotal = res.RowCount;
                $("#gdCheckInfo").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
            });
        },
        //绑定工序下拉框
        bindSpecData: function (productId) {
            page.post(page.url, { action: "GetSpecInfoByProductId", productId: productId }, false, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                $("#txtWorkflowStepName_ef").combobox({
                    valueField: 'WORKFLOWSTEPID',
                    textField: 'WORKFLOWSTEPNAME',
                    panelHeight: 200,
                    data: res.DBTable //下拉数据
                });
            });
        },
        //绑定编辑区域数据
        bindEditFormData: function (rowData) {
            $("#txtPhysicoChemicalCheckId").val(rowData.CHECKID); //主键ID
            $("#productContent").productCombo("setCombo", { productName: rowData.PRODUCTNAME, productID: rowData.PRODUCTID });  //件号
            $("#productContent").productCombo("setValue", rowData.PRODUCTID);  //件号下拉默认
            $("#txtWorkflowStepName_ef").combobox("setText", rowData.WORKFLOWSTEPNAME); //工序
            $("#txtCheckItemName_ef").combobox("setText", rowData.CHECKITEMNAME); //检测项目
            $("#txtCheckStandard_ef").textbox("setValue", rowData.CHECKSTANDARD); //检测标准
        },
        //保存数据
        saveData: function () {
            var vaild = $('#editForm').form('validate');
            if (vaild === false) {
                displayMessage("请填写必填项", false);
                return;
            }
            var params = {
                physicoChemicalCheckId: $("#txtPhysicoChemicalCheckId").val(),
                productID: $("#productContent").productCombo("getValue"),
                productName: $("#productContent").productCombo("getText"),
                workflowStepID: $("#txtWorkflowStepName_ef").combobox("getValue"),
                workflowStepName: $("#txtWorkflowStepName_ef").combobox("getText"),
                checkItemName: $("#txtCheckItemName_ef").combobox("getText"),
                checkStandard: $("#txtCheckStandard_ef").textbox("getText")
            };
            if ($.trim(params.productID) === null || $.trim(params.productID) === "") {
                displayMessage("件号必填", false);
                return;
            }
            //            var queryFormData = $("#editForm").serializeArray();
            //            $.each(queryFormData, function () {
            //                params[this.name] = this.value;
            //            });
            page.post(page.url, { action: "SavePhysicoChemicalCheck", paramDatas: JSON.stringify(params) }, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                page.searchData();
                page.clearPage(false, false, true);
            });
        },
        //清除页面（查询区域，列表区域，编辑区域）
        clearPage: function (query, list, edit) {
            if (query) {
                $("#txtCheckItemName_qf").combobox("clear"); //检测项目
                $("#txtProductName_qf").textbox("clear"); //件号
                $("#txtSpecNo_qf").textbox("clear"); //工序号
            }
            if (list) {
                clearEasyuiDataGrid("gdCheckInfo"); //清空列表
                page.pageNumber = 1; page.pageTotal = 0
                $('#pp').pagination('refresh', {
                    total: page.pageTotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            }
            if (edit) {
                $("#txtPhysicoChemicalCheckId").val(""); //将编辑数据ID隐藏框置为空
                $("#productContent").productCombo("init"); //件号
                $("#txtWorkflowStepName_ef").combo("clear");
                $("#txtWorkflowStepName_ef").combo("panel").empty();
                $("#txtCheckItemName_ef").combobox("clear"); //检测项目
                $("#txtCheckStandard_ef").textbox("clear"); //检测标准
            }
        },
        //post数据（路径，参数，是否异步，成功返回方法）
        post: function (url, param, async, callback) {
            $.ajax({
                type: "Post",
                url: url,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                    $("body").find(".easyui-linkbutton").each(function () {
                        $(this).linkbutton('enable');
                    });
                }
            });
        }
    }
    page.before();
    //页面加载后
    $(function () {
        page.init();
    });
</script>
